package org.example.m6;

import java.util.Date;
import java.util.List;

public class NonResident extends Person {
    private String visaType;//声明私有成员变量visaType(签证类型）

    // 构造方法
    public NonResident(String name, String gender, Date birthDate, String nationality, String visaType) {
        super(name, gender, birthDate, nationality);
        this.visaType = visaType;
    }

    // Getter 和 Setter 方法
    public String getVisaType() {
        return visaType;
    }

    public void setVisaType(String visaType) {
        this.visaType = visaType;
    }

    // 统计函数
    public int countResidentsAndNonResidents(List<Person> population) {
        int residentCount = 0;
        int nonResidentCount = 0;
        for (Person person : population) {
            if (person instanceof Resident) {
               residentCount++; //统计居民数
            } else if (person instanceof NonResident) {
                nonResidentCount++;//统计居民数
            }
        }
        return residentCount + nonResidentCount; // 返回总计数
    }
}
